import { deleteByPrimaryKeyForProUserGeographic, selectByPrimaryKeyForProUserGeographic, insertForProUserGeographic, updateForProUserGeographic, deleteByMapForProUserGeographic,updateByMapForProUserGeographic, getOneForProUserGeographic,getAllForProUserGeographic,queryPageForProUserGeographic, countForProUserGeographic, insertBatchForProUserGeographic, deleteBatchForProUserGeographic,updateBatchForProUserGeographic,getProvincesCitiesCountie,getCascaderAreaTreeByParentid } from '@/services/system/api_prousergeographic';

export default {
    namespace: 'prousergeographic',

    state: {
        data: {
            list: [],
            pagination: {},
        },
        geographicData: {
        	list: [],
        },
    },

    effects: {
            *delete_by_primarykey_for_prousergeographic({ payload }, { call, put }) {
                const response = yield call(deleteByPrimaryKeyForProUserGeographic, payload);
                yield put({
                    type: 'deleteByPrimaryKeyForProUserGeographic',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });


            },
            *select_by_primarykey_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(selectByPrimaryKeyForProUserGeographic, payload);
                yield put({
                    type: 'selectByPrimaryKeyForProUserGeographic',
                    payload: response,
                });

                if (callback) callback();
            },
            *insert_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(insertForProUserGeographic, payload);
                yield put({
                    type: 'insertForProUserGeographic',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(updateForProUserGeographic, payload);
                yield put({
                    type: 'updateForProUserGeographic',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *delete_by_map_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(deleteByMapForProUserGeographic, payload);
                yield put({
                    type: 'deleteByMapForProUserGeographic',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_by_map_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(updateByMapForProUserGeographic, payload);
                yield put({
                    type: 'updateByMapForProUserGeographic',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *get_one_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(getOneForProUserGeographic, payload);
                yield put({
                    type: 'getOneForProUserGeographic',
                    payload: response,
                });

                if (callback) callback();
            },
            *get_all_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(getAllForProUserGeographic, payload);
                yield put({
                    type: 'getAllForProUserGeographic',
                    payload: response,
                });

                if (callback) callback();
            },
            *query_page_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForProUserGeographic, payload);
                yield put({
                    type: 'queryPageForProUserGeographic',
                    payload: response,
                });

                if (callback) callback();
            },
            *count_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(countForProUserGeographic, payload);
                yield put({
                    type: 'countForProUserGeographic',
                    payload: response,
                });


                if (callback) callback();
            },
            *insert_batch_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(insertBatchForProUserGeographic, payload);
                yield put({
                    type: 'insertBatchForProUserGeographic',
                    payload: response,
                });


                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });


                if (callback) callback();
            },
            *delete_batch_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(deleteBatchForProUserGeographic, payload);
                yield put({
                    type: 'deleteBatchForProUserGeographic',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *update_batch_for_prousergeographic({ payload, callback }, { call, put }) {
                const response = yield call(updateBatchForProUserGeographic, payload);
                yield put({
                    type: 'updateBatchForProUserGeographic',
                    payload: response,
                });

                const responsedata = yield call(queryPageForProUserGeographic, {});
                yield put({
                type: 'queryPageForProUserGeographic',
                payload: responsedata,
                });

                if (callback) callback();
            },
            *get_provinces_cities_countie({ payload, callback }, { call, put }) {
                const response = yield call(getProvincesCitiesCountie, payload);
                yield put({
                    type: 'getProvincesCitiesCountie',
                    payload: response,
                });
                
                if (callback) callback();
            },
            *get_cascader_areatree_by_parentid({ payload, callback }, { call, put }) {
                const response = yield call(getCascaderAreaTreeByParentid, payload);
                yield put({
                    type: 'getCascaderAreaTreeByParentid',
                    payload: response,
                });
                
                if (callback) callback();
            },
            },

    reducers: {
        deleteByPrimaryKeyForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        selectByPrimaryKeyForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteByMapForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateByMapForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getOneForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getAllForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        queryPageForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        countForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertBatchForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteBatchForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateBatchForProUserGeographic(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getProvincesCitiesCountie(state, action) {
            return {
                ...state,
                geographicData: action.payload,
            };
        },
        getCascaderAreaTreeByParentid(state, action) {
            return {
                ...state,
                geographicData: action.payload,
            };
        },
    },
};
